package cn.edu.hpu.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import hirondelle.date4j.DateTime;

	public class DateUtil {
		public static String getDate(String date,int day){
			DateTime datetime = new DateTime(date);
			return datetime.plusDays(day).toString();
	}
	
	public static String getTime(){
		Date date = new Date();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		return format.format(date);
	}
	
	public  static int getDifferDays(String startdate,String enddate){
		  SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
		  Date date1 = null;
		  Date date2 = null;
		  int days = 0;
		  try {
			date1 = f.parse(startdate);
			date2 = f.parse(enddate);
			days = (int) ((date2.getTime()-date1.getTime())/86400000);
		} catch (ParseException e) {
			
			e.printStackTrace();
		}
		 return days;
	}

}
